<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: strVerify.js</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Source: strVerify.js</h1>

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>/**
 * @description **验证字符串长度范围**
 * @param {String} value
 * @param {Number} minLength 最小长度
 * @param {Number} maxLength 最大长度
 * @returns Boolean
 * @example
 *
 * ```js
 * let str='ab'
 * lengthRange(str,1,2)
 * ```
 * 
 */
const lengthRange=(value,minLength,maxLength)=>{
    return Boolean(value.length >= minLength &amp;&amp; value.length &lt;= maxLength);
}


/**
 * @description **验证字符串是否以字母开头**
 * @param {String} value
 * @returns Boolean
 */
const letterBegin=(value)=>{
    return /^[A-z]/.test(value);
}


/**
 * @description **验证字符串是否为纯数字**
 * @param {String} value
 * @returns Boolean
 */
const pureNum=value=>{
    return /^[0-9]*$/.test(value);
}


/**
 * @description **验证大陆邮政编码**
 * @param {String} value
 * @returns Boolean
 */
const isMail=value=>{
    return /^[1-9][0-9]{5}$/.test(value.toString());
}


/**
 * @description **验证二代身份证；共18位，最后一位可为x**
 * @param {String} value
 * @returns Boolean
 */
const isIdCard=value=>{
    return /^[1-9][0-9]{5}(18|19|(2[0-9]))[0-9]{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)[0-9]{3}[0-9Xx]$/.test(value);
}


/**
 * @description **验证是否为网址**
 * @param {String} value
 * @returns Boolean
 */
const isURL=value=>{
    return /^(https:\/\/|http:\/\/|ftp:\/\/|rtsp:\/\/|mms:\/\/)?[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+[\/=\?%\-&amp;_~`@[\]\':+!]*([^&lt;>\"\"])*$/.test(value);
}


/**
 * @description **验证QQ号；非0开头的5~13位整数**
 * @param {String} value
 * @returns Boolean
 */
const isQQ=value=>{
    return /^[1-9][0-9]{4,12}$/.test(value.toString());
}



/**
 * @description **验证电子邮箱**
 * @param {String} value
 * @returns Boolean
 */
const isEmail=value=>{
    return /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(value);
}


/**
 * @description **验证手机号**
 * @param {String} value
 * @returns Boolean
 */
const isPhone=value=>{
    return /^1[3,4,5,6,7,8,9][0-9]{9}$/.test(value.toString());
}


/**
 * @description **验证电话号码**
 * @param {String} value
 * @returns Boolean
 */
const isTel=value=>{
    return /^([0-9]{3,4})?[0-9]{7,8}$|^([0-9]{3,4}-)?[0-9]{7,8}$/.test(value);
}

export {lengthRange,letterBegin,pureNum,isMail,isIdCard,isURL,isQQ,isEmail,isPhone,isTel}</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#cookieAdd">cookieAdd</a></li><li><a href="global.html#cookieGet">cookieGet</a></li><li><a href="global.html#haveCNChars">haveCNChars</a></li><li><a href="global.html#haveSpace">haveSpace</a></li><li><a href="global.html#isAndroid">isAndroid</a></li><li><a href="global.html#isApple">isApple</a></li><li><a href="global.html#isEmail">isEmail</a></li><li><a href="global.html#isIdCard">isIdCard</a></li><li><a href="global.html#isMail">isMail</a></li><li><a href="global.html#isMobile">isMobile</a></li><li><a href="global.html#isPhone">isPhone</a></li><li><a href="global.html#isQQ">isQQ</a></li><li><a href="global.html#isTel">isTel</a></li><li><a href="global.html#isTest">isTest</a></li><li><a href="global.html#isURL">isURL</a></li><li><a href="global.html#isWeixin">isWeixin</a></li><li><a href="global.html#lengthRange">lengthRange</a></li><li><a href="global.html#letterBegin">letterBegin</a></li><li><a href="global.html#localStorageAdd">localStorageAdd</a></li><li><a href="global.html#localStorageGet">localStorageGet</a></li><li><a href="global.html#pureNum">pureNum</a></li><li><a href="global.html#sessionStorageAdd">sessionStorageAdd</a></li><li><a href="global.html#sessionStorageGet">sessionStorageGet</a></li><li><a href="global.html#strDelRight">strDelRight</a></li><li><a href="global.html#strJoin">strJoin</a></li><li><a href="global.html#strTrim">strTrim</a></li><li><a href="global.html#timeStamp">timeStamp</a></li><li><a href="global.html#totalPage">totalPage</a></li><li><a href="global.html#urlParamAdd">urlParamAdd</a></li><li><a href="global.html#urlParamGet">urlParamGet</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Mon Nov 22 2021 17:08:01 GMT+0800 (中国标准时间)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
